package cn.xfdzx.android.apps.shop.presenter;

import cn.xfdzx.android.apps.shop.base.BasePresenter;
import cn.xfdzx.android.apps.shop.bean.BaseObjectBean;
import cn.xfdzx.android.apps.shop.bean.CategoryAllBeen;
import cn.xfdzx.android.apps.shop.bean.LoginBean;
import cn.xfdzx.android.apps.shop.bean.OneCategoryBeen;
import cn.xfdzx.android.apps.shop.bean.TwoCategoryBeen;
import cn.xfdzx.android.apps.shop.contract.OneCategoryContract;
import cn.xfdzx.android.apps.shop.contract.OneLoginContract;
import cn.xfdzx.android.apps.shop.model.OneCategoryModel;
import cn.xfdzx.android.apps.shop.model.OneLoginModel;
import cn.xfdzx.android.apps.shop.net.RxScheduler;
import io.reactivex.functions.Consumer;

/**
 * @author
 * @date Description：
 */
public class OneCategoryPresenter extends BasePresenter<OneCategoryContract.View> implements OneCategoryContract.Presenter {

    private OneCategoryContract.Model model;

    public OneCategoryPresenter() {
        model = new OneCategoryModel();
    }


    @Override
    public void initData(String index_status) {
        if (!isViewAttached()) {
            return;
        }
        mView.showLoading();
        model.initData( index_status)
                .compose(RxScheduler.<CategoryAllBeen>Flo_io_main())
                .as(mView.<CategoryAllBeen>bindAutoDispose())
                .subscribe(new Consumer<CategoryAllBeen>() {
                    @Override
                    public void accept(CategoryAllBeen bean) throws Exception {
                        mView.onInitSuccess(bean);
                        mView.hideLoading();
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        mView.onError(throwable);
                        mView.hideLoading();
                    }
                });
    }


}
